package com.qingyun.customview.bezier

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.qingyun.customview.R
import com.qingyun.customview.bezier.cart.CartBezierActivity
import com.qingyun.customview.bezier.path_anim.PathBezierActivity
import com.qingyun.customview.databinding.ActivityBezierBinding

class BezierActivity : AppCompatActivity() {
    companion object {
        fun start(context: Context) {
            context.startActivity(Intent(context, BezierActivity::class.java))
        }
    }

    private val binding by lazy {
        ActivityBezierBinding.inflate(layoutInflater)
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(binding.root)
        ViewCompat.setOnApplyWindowInsetsListener(binding.root) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
    }

    fun onClick(view: View) {
        when (view.id) {
            R.id.btnSimpleBezier -> {
                SimpleBezierActivity.start(this)
            }

            R.id.btnAddCart -> {
                CartBezierActivity.start(this)
            }

            R.id.btnPathAnim -> {
                PathBezierActivity.start(this)
            }
        }
    }
}